package com.zsl.provider.ctrl;

import com.zsl.provider.service.EurekaService;
import com.zsl.provider.service.HealthStatusService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 *
 */
@RestController
public class TestCtrl {


	@Resource
	private EurekaService eurkaService;

	@Resource
	private HealthStatusService healthStatusService;

	@Value("${server.port}")
	String port;


	@GetMapping("/test")
	public String getHealth(){
		return "OK-" + port;
	}



	@GetMapping("/getProviderStatus")
	public String getProviderStatus(){
		return healthStatusService.getStatus();
	}

	@GetMapping("/provider/up")
	public String providerUp(){
		 healthStatusService.setStatus(true);
		 return healthStatusService.getStatus();
	}

	@GetMapping("/provider/down")
	public String providerDown(){
		healthStatusService.setStatus(false);
		return healthStatusService.getStatus();
	}


}
